import request from "@/units/request"
import {HttpResult, HttpResultData} from "@/types/project";


/**
 * 弹出组件
 * 获取资源库资源
 */
export const getResourcesListApi = (where: object): Promise<HttpResultData<any>> => request(`/data-resources/list`, where)


/**
 * 页面获取数据
 * @param where
 */
export const getResourcesDataApi = (where: object): Promise<HttpResultData<any>> => request(`/data-resources/index`, where)


/**
 * 获取上传配置
 */
export const getUploaderConfigureApi = (type: string): Promise<HttpResultData<any>> => request(`/data-resources/uploader-configure`, {type})


/**
 * 记录数到资源库
 * @param data
 */
export const recordRepositoryApi = (data: any[]): Promise<HttpResult> => request(`/data-resources/record`, {list: data}, 'POST')


/**
 * 资源重命名
 * @param data
 */
export const renameResourcesApi = (data: any): Promise<HttpResult> => request(`/data-resources/rename`, data, 'POST')


/**
 * 删除资源
 * @param id
 */
export const removeResourcesApi = (id: number[]): Promise<HttpResult> => request(`/data-resources/remove`, {id}, 'POST')


/**
 * 移动资源
 * @param data
 */
export const moveCateApi = (data: { id: number[], cate_id: number }): Promise<HttpResult> => request(`/data-resources/move-cate`, data, 'POST')


/**
 * 获取资源分类
 */
export const getResourcesCateListApi = (where: any): Promise<HttpResult> => request(`/data-resources/cate-list`, where)


/**
 * 创建资源分类API
 */
export const createdResourcesCateApi: string = '/data-resources/created-cate'


/**
 * 编辑资源分类
 * @param where
 * @returns {*}
 */
export const updatedResourcesCateApi = `/data-resources/updated-cate`

/**
 * 资源上传接口地址
 */
export const uploaderApi: string = `/data-resources/uploader`


/**
 * 删除资源分类API
 * @param where
 */
export const deleteResourcesCateApi = (where: { id: number }): Promise<HttpResult> => request(`/data-resources/delete-cate`, where, 'POST')
